import React from 'react'
import PropTypes from 'prop-types'
import { connect } from 'react-redux'
import { withRouter } from 'react-router-dom'
import { checkDataOverviewData, checkHeroList } from '../../actions/couponManage/couponAnalysis'
import { dataOverviewData, heroList, heroTotal } from '../../reducers/CouponManage/couponAnalysis'
import CouponAnalysis from '../../views/CouponManage/CouponAnalysis/index'
import { bindActionCreators } from 'redux'

const CouponContainer = ({dataOverviewData, heroList, heroTotal, checkDataOverviewData, checkHeroList}) => {    
    return <CouponAnalysis 
        dataOverviewData={dataOverviewData}
        heroList={heroList}
        heroTotal={heroTotal}
        onCheckDataOverviewData={(data)=> checkDataOverviewData(data)}     
        onCheckHeroList={(data)=> checkHeroList(data)}                
    />
}

CouponContainer.propTypes = {
    dataOverviewData: PropTypes.object,
    heroList: PropTypes.array,
    heroTotal: PropTypes.number,
    checkDataOverviewData: PropTypes.func,
    checkHeroList: PropTypes.func,
}

const mapStateToProps  = (state) =>({
    dataOverviewData:dataOverviewData(state.couponAnalysis),
    heroList:heroList(state.couponAnalysis),
    heroTotal:heroTotal(state.couponAnalysis),
})


const mapDispatchToProps = (dispatch) => ({
    checkDataOverviewData: bindActionCreators(checkDataOverviewData,dispatch),
    checkHeroList: bindActionCreators(checkHeroList,dispatch),
})

export default withRouter(connect(
    mapStateToProps,
    mapDispatchToProps
  )(CouponContainer))